<?php
class ManageBanIpForm extends Form{
	function ManageBanIpForm(){
		CGlobal::$website_title="Quản trị kiểm duyệt ip";
		$this->link_css('style/admin.css');
		Form::Form('ManageBanIpForm');
	}
	function on_submit(){
		if(Url::get("del_all")=="Xóa ip được chọn")
		{
			$ids = (isset($_POST['chk_id']))?$_POST['chk_id']:array(); 
			$ip_ids='';							
			if(count($ids)>0){		
				for($i=0;$i<count($ids);$i++){
					$ip_ids.=($ip_ids?',':'').$ids[$i];
				}		
				DB::query('DELETE FROM ban_ip WHERE id IN('.$ip_ids.')');		
				Url::redirect_url(Url::build_all(array('chk_id','del_all','cmd','id')));		
			}	
		}
		
	}	
	function draw(){
		//xoa 1 id
		if(Url::get("act")=="del" && Url::get('id')){
			DB::query('DELETE FROM ban_ip WHERE id='.Url::get('id'));
			Url::redirect_url(Url::build_all(array('chk_id','del_all','act','id')));
		}
		global $display;
		//list
		$this->beginForm();
		$items = array();
		$sql = "SELECT * FROM ban_ip Order by id desc";
		$result = DB::query($sql);
		while ($row = mysql_fetch_assoc($result)) {
			$row['create_time'] = date('d/m - h:i',$row['create_time']);
			$items[$row['id']] = $row;
			$arr_mem_cache[$row['ip']] = $row;
		}
		// cho mang vao memcache
		AZMemcache::do_put('list_ban_ip',$arr_mem_cache);
		$display->add('items',$items);
		$display->add('items_json',json_encode ($items));
		$display->output('ManageBanIp');
		$this->endForm();
	}
}
?>